import { getRequest } from '../interceptor'
import { getKeyWordListFilter, convertSearchInfo } from '@/api/search/informationFilter'
import { SEARCH_TYPE } from '@/utils/constant'

export const getHotSearch = (): any => {
  return getRequest('/search/hot/detail')
}

export const getKeyWordLists = (params): any => {
  return getRequest('/search/suggest', params).then(getKeyWordListFilter)
}

export const getSearchInfo = (keywords: string, type: string, offset: number) => {
  return getRequest('/cloudsearch', { keywords, type: SEARCH_TYPE[type].type, limit: SEARCH_TYPE[type].limit, offset: offset * SEARCH_TYPE[type].limit }).then((res) => convertSearchInfo(res, type))
}
